/**
 * 
 */
package com.softsec.isc.analysis;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author huge
 *
 */
public class GetClassName {
	
	public static void ClassName(String fileName) throws IOException{
		int flag = GetFinal.getFlag(fileName);			
		DataInputStream input=apkExtractor.getDexDataInputStreamWithBuffered(fileName);
		int offset=0;
		offset = DexMapItemMapper.getInstance().getDexMapItemOffset(
				"kDexTypeClassDefItem");
		int count = DexMapItemMapper.getInstance().getDexMapItemCount(
				"kDexTypeClassDefItem");
		
		List<String> PackageNameList = new ArrayList<String>();
		
		byte[] bufferArray = new byte[4];			
		if(offset!=0){
			input.skipBytes(offset);			
			for (int i = 0; i < count; i++) {		
				input.read(bufferArray);
				int typeId = GetFinal.GetSixteen(bufferArray, flag);
				PackageNameList.add(DexMapItemMapper.getInstance().getDexType(typeId));
				input.skip(28);				
			}
		}
		
		DexMapItemMapper.getInstance().addResult("packageName", PackageNameList);		
	}
	
}
